<?php
namespace Apps\BoxSns\Model;

use Think\Model;

class SnsNotificationCountModel extends \BaseModel {
	/**
	 *type comment 评论提醒 message 消息提醒 fans 关注提醒
	 ***提醒数字类型加1***
	 */
	function inc($user_id, $type, $step = 1) {
		$where = array('user_id' => $user_id, 'type' => $type);
		$r = $this->where($where)->find();
		if ($r) {
			$bool = $this->where($where)->save(array('count' => $r['count'] + $step));
			//	dump($bool);
		} else {
			$where['count'] = $step;
			$bool = $this->add($where);
		}
		//	dump($bool);
		return $bool;
	}

	/**清除提醒数量*/
	function clear($user_id, $type) {
		return $this->where(array('user_id' => $user_id, 'type' => $type))->save(array('count' => 0));
	}

	/****我的提醒数字*/
	function mycount($user_id) {
		$row = $this->get("user_id='$user_id'");
		return $row;
	}

}
